package com.pinxixi.content.controller;

import com.pinxixi.api.content.ContentControllerApi;
import com.pinxixi.content.service.ContentService;
import com.pinxixi.framework.domain.content.Content;
import com.pinxixi.framework.model.response.ListResponseResult;
import com.pinxixi.framework.model.response.QueryResponseResult;
import com.pinxixi.framework.model.response.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/content")
public class  ContentController implements ContentControllerApi {

    @Autowired
    private ContentService contentService;


    @Override
    @GetMapping("/findAll")
    public ListResponseResult<Content> findAll() {
        return contentService.findAll();
    }

    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody Content content) {
        return contentService.save(content);
    }

    @Override
    @GetMapping("findOne/{id}")
    public QueryResponseResult findOne(@PathVariable("id") Long id) {
        return contentService.findOne(id);
    }

    @Override
    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable("id") Long id) {
        return contentService.delete(id);
    }

    @Override
    @CrossOrigin(origins = "*")
    @GetMapping("/portalContent")
    public ListResponseResult<Content> portalContent() {
        return contentService.portalContent();
    }


}
